<template>
	<view style="background-color: white;">
		<view v-if="zixunHistory.length>0">
			<view class="order-box" v-for="(item,i) in zixunHistory" :key="item.mid">
				<view class="box-b" style="height:30px;display:flex;" @click="goMyZiXunDetail(item.mid)">
					<image :src="switchImg(isNull(item.images)?'':item.images[0].img)" style="height: 40px;width: 40px;margin-top: 12rpx;">
					<view class = "info">
						<view class="number">{{item.gaishu}}</view> 
						<view class="time">{{item.xiangqing}}</view> 
					</view> 
				</view>
			</view>
		</view>
		<!-- <view v-show="zixunHistory.length<1" class="no-goods-box">
			<view>还没有流水记录</view>
		</view> -->
		<view class="tips-text">{{tips}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,				//页数
				zixunHistory:[],	//历史咨询集合
				tips:"上拉加载更多数据",
			}
		},
		onReachBottom() {
			if(this.tips=='上拉加载更多数据'){
				this.page++;
				this.getZiXunHistory();
			}
		},
		methods: {
			//得用户历史咨询
			getZiXunHistory(){
				this.$http.get('/zixun.do', {
					p: 'xcxHistory',
					page:this.page,
					userId:uni.getStorageSync('usersId')
				}).then(res => {
					if(res.data.length>0){
						this.zixunHistory=this.zixunHistory.concat(res.data);
						if(res.data.length < 20 && this.page == 1){
							this.tips="";
						}else if(res.data.length < 20){
							this.tips="没有更多数据";
						}
						// console.log(this.zixunHistory)
					}else{
						if(this.page == 1){
							this.tips="您还没有咨询记录";
						}
					}
				})
			},
			//跳咨询详情
			goMyZiXunDetail(mid){
				// console.log("咨询ID："+mid)
				uni.navigateTo({
					url:'myZixunDetail?mid='+mid
				})
			},
			//显示图片
			switchImg(image){
				if(this.isNull(image)){
					return "../../static/center/doctor.png"
				}else{
					return this.host + "/image/"+image;
				}
			},
			//判空
			isNull(str){
				return str==null || str=="" || str==undefined
			}
		},
		onLoad() {
			this.getZiXunHistory();
		}
	}
</script>

<style>
	*{margin:0px;padding:0px;}
	html,body{width:100%;height:100%;}
	#refreshContainer{
		width:100%;
		height:100%;
	}
	.time,.ways,.detail{
		font-size: 14px;
		color: #909399;
	}
	.order-box{
		padding: 30rpx 0 60rpx 30rpx;
		border-bottom: 1px #d1d1d1 solid;
	}
	#houtai {
		background-image: url(${pageContext.request.contextPath}/weixin/img/center/dianpu.png);
	}
	.info {
		float: left;
		width: 100%;
		margin-left: 20px;
	}
	.number {
		font-size: 15px;
		color: #000000;
		margin-bottom: 5px;
		overflow: hidden;
		-webkit-line-clamp: 1;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}
	.time {
		font-size: 14px;
		overflow: hidden;
		-webkit-line-clamp: 1;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}
	.ways {
		float: left;
		margin-left: 20px;
	}
	.nav-header h1 {
		text-align: left;
	}
	.nav-header a {
		color: white;
	}
	.tips-text,.no-goods-box{
		padding: 10px 0 10px 0;
		text-align: center;
	}
</style>
